'use strict'
import { _xhb_map_loadScript, _xhb_map_waitForParameterReady } from '../../../utils/util.js'

class _EGisComponent {
    constructor(opt) {
        this.options = opt;
    }
    initMap() {
        _xhb_map_loadScript('./lib/egis/js/egis.min-1.4.9.js', () => {
            let resolutions = [156543.03392, 78271.516964, 39135.758482, 19567.879241, 9783.9396205, 4891.9698102, 2445.9849051, 1222.9924525, 611.49622628, 305.74811314, 152.87405657, 76.437028285, 38.218514142, 19.109257071, 9.5546285356, 4.7773142678, 2.3886571339, 1.1943285669, 0.5971642834, 0.2985821417, 0.14929107085, 0.07464553542, 0.03732276771, 0.03732276771 / 2, 0.03732276771 / 4, 0.03732276771 / 8];
            let origin = [11584788.247814529, 3591253.0144172735];
            let crs = new egis.CRS({
                resolutions: resolutions, origin: origin
            })
            const SGMapLayerUrl = {
                jsurl: 'http://map-bj.sgcc.com.cn/api/epgis-js-1.5.3.min.js',
                cssurl: 'http://map-bj.sgcc.com.cn/api/epgis-1.5.3.css',
                key: '18617c32d2ff3827a6d9f8cd0a5bb58a',
                sn: '22e3e6cce79531b4ad9b6371da592e54',
                style: "aegis://styles/aegis/StreetsDark",
                // style: mapStyle

            }
            let map = egis.map(this.options.mapContainer, {
                center: this.options.center,//中心点
                zoom: this.options.zoom, //默认层级
                crsCode: "",
                crs: crs,
                minZoom: 7,
                maxZoom: 22,
                zoomDelta: 1, //双击放大的层级差，1即放大一级
                noWrap: true,
                wheelDebounceTime: 100,
                boxZoom: false,
                zoomSnap: 1,
                doubleClickZoom: false,
                zoomControl: false,
                attrControl: false,
                scaleControl: false,
            });
            let layer = new egis.layer.SGLayer(SGMapLayerUrl);
            window.globalMap.status = true;
            map.addLayer(layer)
            console.log('思极地图初始化成功')
        })
    }

    addMarker(id, options, markerEvent) {
        // let marker = new epgis.Marker().setLngLat([118, 24.5]);
        // var point = new BMapGL.Point(position[0], position[1]);
        // let marker = new BMapGL.Marker(point);        // 创建标注   
        // window.globalMap.map.addOverlay(marker);                     // 将标注添加到地图中
        // window.globalMap.markers.push({ id, marker })
    }

    delMarker(id) {
        // window.globalMap.markers.filter(o => o.id === id).forEach(o => window.globalMap.map.removeOverlay(o.marker))
    }
}
export default _EGisComponent